<template>
	<view>
		<cu-custom bgImage="https://image.weilanwl.com/color2.0/plugin/wdh2236.jpg" :isBack="true">
			<block slot="backText" style="font-weight: bold;">返回</block>
			<block slot="content">
				<image src="/static/images/sportList.png" mode="aspectFill" style="width: 240upx;height: 60upx;"></image>
			</block>
		</cu-custom>
		
		<view class="cu-list menu-avatar">
			<view class="cu-item" style="height:190rpx;" v-for="(item,key) in sportHistoryData" :key="key" @click="goDetail(item)">
				<view class="cu-avatar radius lg" style="background-image:url(https://zhhq.lzfsd.com/images/zhty/run_logo.jpg);height:80px;left:15rpx;width:120rpx;"></view>
				<view class="content">
					<view><view style="color:#AEAEAE;">{{item.sportTime}} {{item.typeText}}</view></view>
					<view><view style="color:#584e66;font-weight:bold;font-size:40upx;">{{item.totalDistance}}公里</view></view>
					<view class="text-gray text-sm flex"><view class="text-cut">时长:{{item.time.hour}}:{{item.time.minute}}:{{item.time.second}} 速度:{{item.speed}} 热量:{{item.calorie}}</view></view>
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				sportHistoryData:[]
			}
		},
		
		onLoad() {
			this.loadData();
		},
		
		onShow() {
			
		},
		methods: {
			loadData:function(){
				var me = this;
				var temp_sportHistoryData = uni.getStorageSync('sportHistoryData');
				for (var i = temp_sportHistoryData.length-1; i > -1; i--) {
					var item = temp_sportHistoryData[i];
					if(item.type == 0){
						item.typeText = "户外跑";
					}else if(item.type == 1){
						item.typeText = "骑行";
					}
					me.sportHistoryData.push(item);
				}
			},
			
			goDetail:function(sportItem){
				uni.navigateTo({
					url: "/pages/sport/finish?detailDate=" + encodeURIComponent(JSON.stringify(sportItem))
				});
			}
		}
	}
</script>

<style>
</style>
